//////////////////////////////////////////////////////////////////////////
//	File: Mesh.h
//
//	Author:	Omar Khan
//
//	Created: January 11, 2010
//
//	Purpose: Rendering a mesh to the screen
//////////////////////////////////////////////////////////////////////////
#pragma once

#include <d3dx9.h>
#include <vector>

class CMesh
{

	friend class CMeshInstance;


private:
	IDirect3DDevice9 *m_pDevice;
	ID3DXMesh *m_pMesh;
	std::vector<IDirect3DTexture9*> m_vTextures;
	std::vector<D3DMATERIAL9> m_vMaterials;
	D3DMATERIAL9 m_White;

public:
	CMesh(void);
	CMesh(char szName[], IDirect3DDevice9* dev);
	~CMesh(void);

	HRESULT Load(char szName[], IDirect3DDevice9* dev);
	void Render();
	void Release();

};

class CMeshInstance
{

private:
	CMesh *m_pMesh;
	D3DXVECTOR3 m_Pos, m_Rot, m_Scale;


public:
	CMeshInstance();
	CMeshInstance(CMesh *pMesh);
	void Render();

	inline void SetMesh(CMesh *pMesh)			{ m_pMesh = pMesh; }
	inline void SetPosition(D3DXVECTOR3 vPos)	{ m_Pos = vPos; }
	inline void SetRotation(D3DXVECTOR3 vRot)	{ m_Rot = vRot; }
	inline void SetScale(D3DXVECTOR3 vScale)	{ m_Scale = vScale; }

	inline CMesh* GetMesh(void) 				{ return m_pMesh; }
	inline D3DXVECTOR3 GetPosition(void)		{ return m_Pos; }
	inline D3DXVECTOR3 GetRotation(void)		{ return m_Rot; }
	inline D3DXVECTOR3 GetScale(void)			{ return m_Scale; }

	D3DXMATRIX GetWorldMatrix(void);
};